package route;

import java.util.ArrayList;
import java.util.List;

public class Route_5 {
	public static int normal_price=0;
	public static int []col= {0,0,0,0};
	public static List<List<Integer>>buggage= new ArrayList<>();//size&weight
	public int free_num=1;
	public int free_weight=0;
	public int extra_money=0;
	public void init(List<List<Integer>>bug,int []co)
	{
		normal_price=0;
		buggage.clear();
		free_num=1;
		free_weight=0;
		extra_money=0;
		for(int i=0;i<bug.size();i++)
		{
			if(bug.get(i).get(0).equals(0))
			{
				List<Integer>tmp = new ArrayList<>();
				tmp.add(bug.get(i).get(1)+bug.get(i).get(2)+bug.get(i).get(3));
				tmp.add(bug.get(i).get(4));
				buggage.add(tmp);
			}
		}//存放所有普通物品
		col=co;
		int []k= {32,32,23,23};
		int []mp= {2,2,2,1};
		free_weight=k[col[2]];
		free_num=mp[col[2]];
	}
	public boolean calculate()
	{
		for(int i=0;i<buggage.size();i++)
		{
			if(buggage.get(i).get(1)>32||buggage.get(i).get(0)>203||
					buggage.get(i).get(1)<2||buggage.get(i).get(0)<60)
			{
				return false;
			}
			else if(free_weight==32)
			{
				if(buggage.get(i).get(0)>158)
				{
					extra_money+=520;
				}
			}
			else if(free_weight==23)
			{
				if(buggage.get(i).get(1)>23&&buggage.get(i).get(1)<=28&&
						buggage.get(i).get(0)>=60&&buggage.get(i).get(0)<=158)
				{
					extra_money+=210;
				}
				else if(buggage.get(i).get(1)>28&&buggage.get(i).get(1)<=32&&
						buggage.get(i).get(0)>=60&&buggage.get(i).get(0)<=158)
				{
					extra_money+=520;
				}
				else if(buggage.get(i).get(1)>=2&&buggage.get(i).get(1)<=23&&
						buggage.get(i).get(0)>158&&buggage.get(i).get(0)<=203)
				{
					extra_money+=520;
				}
				else if(buggage.get(i).get(1)>23&&buggage.get(i).get(1)<=32&&
						buggage.get(i).get(0)>158&&buggage.get(i).get(0)<=203)
				{
					extra_money+=830;
				}
			}
		}
		if(buggage.size()>free_num)
		{
			int extra=buggage.size()-free_num;
			int []p= {830,1100,1590};
			for(int i=0;i<Math.min(extra, 3);i++)
			{
				extra_money+=p[i];
			}
			if(extra>3)
			{
				extra_money+=(extra-3)*p[2];
			}
		}
		return true;
	};
	public static void main(String []args)
	{
		List<List<Integer>>bugg= new ArrayList<>();
		for(int i=0;i<3;i++)
		{
			List<Integer>tmp = new ArrayList<>();
			tmp.add(0);
			tmp.add(20);
			tmp.add(30);
			tmp.add(40);
			tmp.add(20);
			bugg.add(tmp);
		}
		int []se= {0,0,0,0};
		Route_5 dog=new Route_5();
		dog.init(bugg,se);
		if(dog.calculate()==false)
		{
			System.out.println("NOT A STANDARD BUGGAGE");
		}
		else
		{
			System.out.println(dog.extra_money);
		}
	}
}
